package com.heyxampis.newmantis.util.utilitarios;

import java.io.Serializable;
import java.util.Iterator;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.springframework.stereotype.Component;

@Component
public class MensagemUtil implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 9091211078048999078L;

	public static void errorMsg(String titulo, String msg) {

		FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, titulo,
				msg);
		
		FacesContext fc = FacesContext.getCurrentInstance();
		
		fc.getExternalContext().getFlash().setKeepMessages(true);
		fc.addMessage("erro", fm);

	}

	public static void infoMsg(String titulo, String msg) {

		FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_INFO, titulo,
				msg);

		FacesContext fc = FacesContext.getCurrentInstance();
		fc.getExternalContext().getFlash().setKeepMessages(true);
		fc.addMessage("info", fm);

	}

	public static void warnMsg(String titulo, String msg) {

		FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_WARN, titulo,
				msg);

		FacesContext fc = FacesContext.getCurrentInstance();
		
		fc.getExternalContext().getFlash().setKeepMessages(true);
		fc.addMessage("warn", fm);

	}

	public static void fatalMsg(String titulo, String msg) {

		FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_FATAL, titulo,
				msg);
		
		FacesContext fc = FacesContext.getCurrentInstance();

		fc.getExternalContext().getFlash().setKeepMessages(true);
		fc.addMessage("fatal", fm);

	}

}
